<include file="Public/header" title="提交漏洞" banner_selected="nav_item-active"/>
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
<script type="text/javascript">
    var ue = UE.getEditor('post-content',{
        toolbars: [
            ['simpleupload','link','unlink', '|', 'selectall', 'cleardoc'],
        ],
        initialFrameHeight:500,
        zIndex:100
    });
	
	/**恢复自动保存内容
　　setTimeout(function () {
        ue.execCommand('drafts');
    }, 500);  
	**/
</script>
   <style>
       /* 可选，样式设置 */
       textarea {
           width: 100%;
           rows: 5;
           padding: 10px; /* 增加内边距，使文本更易读 */
           font-size: 16px; /* 字体大小 */
       }
   </style>
<div class="container container-report">
            <div>
                <!-- section-subnav 标题-->
                <div class="section section-subnav">
                    <div class="section_subnav">
                        <p class="subnav_title"><a href="#">提交漏洞</a></p>
                    </div>
                </div>
                <!-- section-report 表单 -->
                <div class="section section-report">
                    <div class="section_report">
                        <div class="report_form">
                            <form method="post" action="{:U('post/add')}">
                                <div class="mod-form-block mod-form-block-input mod-form-block-input-name">
                                    <label class="label-required" for="">漏洞名称</label>
                                    <div>
                                        <div>
                                            <input name="title" type="text" placeholder="请输入漏洞名称">
                                        </div>
                                        <span class="formtips-error">您输入的漏洞名称有误，请重新输入</span>
                                    </div>
                                </div>
                                <div class="mod-form-block mod-form-block-select mod-form-block-select-type">
                                    <label class="label-required" for="">漏洞类型</label>
                                    <div>
                                        <div>
                                            <select name="cate_id" class="type_select-2" id="category" onchange="updateChildSelect()">
                                             	<option value="" disabled selected>请选择漏洞类型</option>
                                                <foreach name="category" item="v">
													<option value="{$v.id}"> {$v.title}</option>
												</foreach>
                                            </select>
                                        	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <select name="cate_id2" class="type_select-2" name="" id="subcategory">
                                            	<option value="" disabled selected>请选择漏洞类型</option> 
                                            </select>
                                        </div>
                                        <span class="formtips-error">请您选择漏洞类型</span>
                                    </div>
                                </div>
                                   <div class="mod-form-block mod-form-block-select mod-form-block-select-type">
                                    <label class="label-required" for="">漏洞等级</label>
                                    <div>
                                        <div>
                                            <select name="level_id" class="type_select-2" style="width:100%" name="" id=""> 
                                            	<option value="" disabled selected>请选择漏洞等级</option> 
                                                <option value="1">严重</option>
												<option value="2">高危</option>
												<option value="3">中危</option>
												<option value="4">低危</option>
                                            </select>
                                        </div>
                                        <span class="formtips-error">请您选择漏洞类型</span>
                                    </div>
                                </div>
                                <div class="mod-form-block mod-form-block-textarea mod-form-block-textarea-description">
                                    <label class="label-required" for="">漏洞描述</label>
                                    <div>
                                        <div>
                                            <script id="post-content" name="content" type="text/plain" style="width:100%"></script>
                                        </div>
                                        <span class="formtips-error">您输入的漏洞描述有误，请重新输入</span>
                                    </div>
                                </div>
                                <div class="mod-form-block mod-form-block-input mod-form-block-input-name">
                                    <label class="label-required" for="">影响资产</label>
                                    <div>
                                        <div>
                                            <textarea name="property" style="width: 100%;" rows="5" placeholder="请输入受影响资产，输入域名或者IP即可，无需https://和端口等信息"></textarea>
                                        </div>
                                        <span class="formtips-error">请输入受影响资产，输入域名或者IP即可，无需https://和端口等信息</span>
                                    </div>
                                </div>
                                <div class="mod-form-block mod-form-block-file">
                                    <label for="">上传附件</label>
                                    <div>
                                        <div>
                                            <a href="javascript:;" class="uploader mod-btn mod-btn-black">
                                                <input id="attachment_file" type="file" onchange="submit_attachment();"/>
												<input id="attachment_path" type="hidden" name="attachment" />
                                                选择文件
                                            </a>
                                            <span class="tips-file">格式限制：7z、zip、pdf，请上传小于8M的文件</span>
                                        </div>
										<span id="upload_success" class="formtips-success">上传成功，可继续进行提交</span>
                                        <span id="upload_fail" class="formtips-error">上传失败，请检查文件格式和大小</span>
                                    </div>
                                </div>
                                <div class="mod-form-block mod-form-block-verify">
                                    <label class="label-required" for="">验证码</label>
                                    <div>
                                        <div>
                                            <input name="verify" type="text">
                                            <img id="captcha_img" onclick="refresh_captcha();" class="verify" src="{:U('login/verify')}" alt="点击刷新"/>
                                            <a onclick="refresh_captcha();">换一张</a>
                                        </div>
                                        <span class="formtips-error">您输入的验证码有误，请重新输入</span>
                                    </div>
                                </div>
                                <div class="mod-form-block mod-form-block-submit">
                                    <div>
                                        <p class="tips-submit">在漏洞未修复之前，请不要向外界传播</p>
                                        <button class="mod-btn mod-btn-blue" type="submit">提交漏洞</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="report_remind">
                            <div>
                                <div class="remind_title">
                                    <h2>温馨提示</h2>
                                </div>
                                <div class="remind_wefocus">
                                    <h3>我们关注的内容</h3>
                                    <p>
                                        Web服务漏洞
                                    </p>
                                    <p>
                                        PC客户端软件漏洞
                                    </p>
                                    <p>
                                        手机客户端软件漏洞
                                    </p>
                                    <p>
                                        威胁情报
                                    </p>
                                </div>
                                <div class="remind_wejudge">
                                    <h3>我们的评判标准</h3>
                                    <p style="width:300px;">
	                                  	 标准详情请查看《GSRC漏洞处理和评分标准》
	                                </p> 
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
</div>
<script>
window.onload = function() {
	var parentSelect = document.getElementById("category");
	var id = parentSelect.value;
	if(id > 0){
		console.log(id);
		var childSelect = document.getElementById("subcategory"); 
		$.ajax({
	        url: "__ROOT__/user.php?m=user&c=post&a=ajaxSubCategory",
	        type: "POST",
	        data: {id:id}, 
	        success: function (data) {
	        	 childSelect.innerHTML = `<option value="">请选择漏洞类型</option>`;
	        	 data.forEach(category => {
	                 const option = document.createElement('option');
	                 option.value = category.id; // 设置选项的值
	                 option.textContent = category.title; // 设置选项的文本
	                 childSelect.appendChild(option); // 添加到下拉列表中
	             });
	        }, 
	    }); 
	}
}


function updateChildSelect() {
    // 获取父选择框和子选择框
    var parentSelect = document.getElementById("category");
    console.log(parentSelect);
    var childSelect = document.getElementById("subcategory"); 
    // 清空子选择框
    childSelect.innerHTML = "";
	var id = parentSelect.value; 
    $.ajax({
        url: "__ROOT__/user.php?m=user&c=post&a=ajaxSubCategory",
        type: "POST",
        data: {id:id}, 
        success: function (data) {
        	 childSelect.innerHTML = `<option value="">请选择漏洞类型</option>`;
        	 data.forEach(category => {
                 const option = document.createElement('option');
                 option.value = category.id; // 设置选项的值
                 option.textContent = category.title; // 设置选项的文本
                 childSelect.appendChild(option); // 添加到下拉列表中
             });
        },
        error: function () {
			
        }
    }); 
}
function submit_attachment(){
				$("#upload_fail").css("display","none");
				$("#upload_success").css("display","none");
                var formData = new FormData();
                formData.append("attachment", document.getElementById("attachment_file").files[0]);   
                $.ajax({
                    url: "__ROOT__/user.php?m=user&c=post&a=attachment_upload",
                    type: "POST",
                    data: formData,
                    contentType: false,
                    processData: false,
                    success: function (data) {
                        if (data.code == "200") {
							$("#attachment_path").attr("value",data.savepath);
							$("#upload_success").css("display","block");
                        }else{
							$("#upload_fail").css("display","block");
                        }
                    },
                    error: function () {
						$("#upload_fail").css("display","block");
                    }
                });
}

function clear_draft(){
    localStorage.removeItem('ueditor_preference');
}
</script>
<script>
         function refresh_captcha(){
            var src = "{:U('login/verify')}";
            var random = Math.floor(Math.random()*(1000+1));
            $("#captcha_img").attr("src",src+"&random="+random);

        }
</script>
<include file="Public/footer" />